package com.buaa.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private String code;
    private String msg;
    private T data;

    public static <T> Result<T> success(){
        return new Result("0", "ok",null);
    }

    public static Result success(String code, String msg, Object data){//有参返回正确
        return new Result(code, msg, data);
    }

    public static <T> Result<T> success(T data){
        return new Result("0", "ok", data);
    }

    public static <T> Result<T> error(String code,String msg){
        return new Result(code, msg, null);
    }

    public static <T> Result<T> error(String msg){ //默认一个错误类
        return new Result("500",msg,null);
    }
}
